// https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json?ct=%E5%8C%97%E4%BA%AC&ci=1&channelId=4
const http = require('http')
const https = require('https')
const url = require('url')
http.createServer((req, res) => {
    let urlObj = url.parse(req.url, true)
    res.writeHead(200, {
        "Content-Type": "application/json;chareet=utf-8",
        "access-control-allow-origin": "*"
    })
    switch(urlObj.pathname) {
        case '/blog/list':
            getCatEye(res)
            break;
        default: 
            res.end('404')
    }
}).listen(9090)
function getCatEye(response) {
    let data = ''
    https.get('https://i.maoyan.com/api/mmdb/movie/v3/list/hot.json?ct=%E5%8C%97%E4%BA%AC&ci=1&channelId=4', res => {
        res.on('data', chunk => {
            data += chunk
        })
        res.on('end', () => {
            response.end(data)
        })
    })
}